import pandas as pd

def check_refunded_orders(file_path):
    """Check if refunded orders are included in detail sheets"""
    print(f"Checking refunded orders in: {file_path}")
    
    excel_file = pd.ExcelFile(file_path)
    detail_sheets = [sheet for sheet in excel_file.sheet_names if "明细" in sheet]
    
    for sheet in detail_sheets:
        print(f"\nExamining sheet: {sheet}")
        df = pd.read_excel(file_path, sheet_name=sheet)
        
        if "订单状态" in df.columns:
            refunded = df[df["订单状态"] == "已退款"]
            refunded_count = len(refunded)
            
            print(f"  Total rows: {len(df)}")
            print(f"  Refunded orders: {refunded_count}")
            
            if refunded_count > 0:
                print("  First refunded order(s):")
                for idx, row in refunded.head(2).iterrows():
                    print(f"    订单号: {row['订单号']}, 订单状态: {row['订单状态']}")
        else:
            print("  WARNING: No '订单状态' column found")

if __name__ == "__main__":
    file_path = "企业结算对账单.xlsx"
    check_refunded_orders(file_path) 